//#include "get_hw_addrs.c"
#ifndef ODR_H
#define ODR_H

#include "globals.h"

// Instance Variables

int stalenessTime;
struct hwa_info *hwaInfo;

typedef struct pfSocketInformation {
	int* sockfd;
	char** interfaceName;
	struct sockaddr** hardwareAddress;
	int* interfaceIndex;
	int socketCount;
} pfSocketInformation;

struct pfSocketInformation pfSocketInfo;

typedef struct domainSocketInformation {
	int sockfd;
} domainSocketInformation;

struct domainSocketInformation domainSocketInfo;

typedef struct routingTable_struct {
	char destination[IPSIZE];
	unsigned char nextHop[ETH_ALEN];
	int outgoingInterfaceIndex;
	int numberOfHops;
	time_t timeStamp;
}routingtable_data;

typedef struct routingtable_list_struct {
	routingtable_data *route_data;
	struct routingtable_list_struct *next;
}routing_table_list;

struct routingtable_list_struct routingTableHead;

typedef struct odr_req_struct{
	int type;
	int hopcount;
	int sourceindex;
	int forcerediscover;
	int repsent;
	struct req_recv_message odr_req_recv;
}odr_request;

typedef struct odr_rep_struct {
	int type;
	int hopcount;
	struct req_recv_message odr_req_recv;
}odr_rep;

typedef struct payload_struct {
	int type;
	int hopcount;
	int sourceport;
	int destport;
	char sourceip[IPSIZE];
	char destip[IPSIZE];
//	int datalen;
	char message[30];
}payload;

// Methods

int main(int argc, char **argv);
int obtainInterfaceInformation();
int createPFPacketSocket();
int createDomainSocket();
int buildInitialRoutingTable();
int updateRoutingTable();
int monitorSockets();

int monitorDomainSocket(int sockfd, rreq_id_list *id_head);
int monitorPacketSocket(int sockfd, rreq_id_list *id_head);
int floodRREQ(odr_request *odr_req, int forcedDiscovery, struct sockaddr *sourceaddr, int inIndex);
int generateRREQ(int sockfd, odr_request *odr_req, struct sockaddr *hardwareAddress, int hardwareIndex, int forcedDiscovery, struct sockaddr *destaddr);
int generateRREP();
struct hwa_info *Get_hw_addrs();
#endif /* ODR_H */

